package com.qf.config;

import com.qf.filter.LoginFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class WebConfig {

    @Bean
    public FilterRegistrationBean<LoginFilter> filterRegistrationBean() {
        FilterRegistrationBean<LoginFilter> filterRegistrationBean = new FilterRegistrationBean();
        LoginFilter loginFilter = new LoginFilter();

        filterRegistrationBean.setOrder(2);  //获取其的顺序
        filterRegistrationBean.addUrlPatterns("/*"); //拦截的url地址
        filterRegistrationBean.setFilter(loginFilter); //添加过滤器
        filterRegistrationBean.setName("loginFilter"); //设置过滤器的名字
        return filterRegistrationBean;
    }
}
